﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using ObjectLibrary;
// -----------------------------------------------------------------------
// <copyright file="$safeitemrootname$.cs" company="$registeredorganization$">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
namespace _0912089_0912172
{
    public abstract class MyForm : VisibleGameEntity3D
    {
        protected List<bool> _lstKBState;

        protected List<MyButton> _buttons;

        public List<MyButton> Buttons
        {
            get { return _buttons; }
            set
            {
                _buttons = value;
                NButton = value.Count;
            }
        }

        protected int _nButton;

        public int NButton
        {
            get { return _nButton; }
            set { _nButton = value; }
        }

        protected int buttonChosenIndex = 0;

        public int ButtonChosenIndex
        {
            get { return buttonChosenIndex; }
            set
            {
                if (value >= NButton)
                    buttonChosenIndex = 0;
                else if (value <= -1)
                    buttonChosenIndex = NButton - 1;
                else
                    buttonChosenIndex = value;

                for (int i = 0; i < NButton; i++)
                {
                    _buttons[i].IsChosen = false;
                }
                _buttons[buttonChosenIndex].IsChosen = true;
            }
        }

        public virtual void HandleKeyBoardInput()
        {
        }

        public virtual void HandleMouseInput()
        {
        }

        public override void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Effect effect, MyCamera camera)
        {
            _model.Draw(gameTime, graphicsDevice, effect, camera);
            for (int i = 0; i < NButton; i++)
            {
                Buttons[i].Draw(gameTime, graphicsDevice, effect, camera);
            }
        }

        public override void Update(GameTime gameTime)
        {
            for (int i = 0; i < NButton; i++)
            {
                Buttons[i].Update(gameTime);
            }
            base.Update(gameTime);
        }
    }
}
